package com.passion.fs.config;

import com.passion.config.MvcConfig;
import com.passion.fs.interceptor.WebPageInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

import javax.annotation.Resource;

/**
 * 类描述：MVC配置
 *
 * @author ZhuYin
 * @since 2025年01月10日
 */
@Slf4j
@Configuration
public class CustomMvcConfig extends MvcConfig {

    @Resource
    private WebPageInterceptor webPageInterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }

    /**
     * 方法说明：注册拦截器
     *
     * @param registry 注册中心
     * @author ZhuYin
     * @since 2025年01月10日
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(webPageInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/static/**", "/login", "/logout", "/doLogin", "/logout");
    }
}
